package com.emm.yixun.mobile.customview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ScrollView;

public class MyScrollView extends ScrollView {
//	private GestureDetector mGestureDetector;
//	View.OnTouchListener mGestureListener;
//	Context context;
//
//	public MyScrollView(Context context, AttributeSet attrs) {
//		super(context, attrs);
//		this.context = context;
//		mGestureDetector = new GestureDetector(context, new YScrollDetector());
//		setFadingEdgeLength(0);
//	}
//
//	@Override
//	public boolean onInterceptTouchEvent(MotionEvent ev) {
//		return super.onInterceptTouchEvent(ev) && mGestureDetector.onTouchEvent(ev);
//	}
//
//	// Return false if we're scrolling in the x direction
//	class YScrollDetector extends SimpleOnGestureListener {
//		@Override
//		public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
//			if (Math.abs(distanceY) > Math.abs(distanceX)) {
//				return true;
//			}
//			return false;
//		}
//	}
//
//	@Override
//	protected void onScrollChanged(int l, int t, int oldl, int oldt) {
//		// if (t + getHeight() >= computeVerticalScrollRange()) {
//		// } else if (t <= 0) {
//		// }
//	}
	
	 private GestureDetector mGestureDetector;   
	    View.OnTouchListener mGestureListener;   
	    
	    public MyScrollView(Context context, AttributeSet attrs) {   
	        super(context, attrs);   
	        mGestureDetector = new GestureDetector(new YScrollDetector());   
	        setFadingEdgeLength(0);   
	    }   
	    
	    @Override  
	    public boolean onInterceptTouchEvent(MotionEvent ev) {   
	        return super.onInterceptTouchEvent(ev) && mGestureDetector.onTouchEvent(ev);   
	    }   
	    
	    // Return false if we're scrolling in the x direction     
	    class YScrollDetector extends SimpleOnGestureListener {   
	        @Override  
	        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {   
	            if(Math.abs(distanceY) > Math.abs(distanceX)) {   
	                return true;   
	            }   
	            return false;   
	        }   
	    }   
	
}